<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 61741
  Date: 2018/5/23
  Time: 10:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>个人信息更改</title>
    <jsp:include page="../../common/header.jsp"></jsp:include>
    <jsp:include page="../../common/cloud-head.jsp"></jsp:include>
    <jsp:include page="../../common/dt.jsp"></jsp:include>
    <script type="text/javascript" src="${ctx}/resources/pagination/script/jquery.pagination.js"></script>
    <link href="${ctx}/resources/pagination/style/pagination.css" rel="stylesheet" type="text/css">
    <link href="${ctx}/resources/pagination/style/common.css" rel="stylesheet" type="text/css">
    <style>
        .content {
            width:60%;
            margin:0 auto;
            padding:10rem;
            background:#F0F0F0
        }
        input{
            color:#111010
        }
        .regist-button a{
            display:block;
            height:2rem;
            width:8rem;
            margin:2rem auto;
            font-size:1rem;
            line-height:2rem;
            color:#FFFFFF;
            background:#F5489F;
            border-radius:0.5rem;
            cursor:pointer;
            position:absolute;
            right:25%;
            text-align:center;
        }
    </style>
</head>
<body>
<div id="user-info">

</div>
<script type="text/html" id="authInfoTmpl">
    <form action="${ctx}/register/register" id="register-form" method="post" >
        <div class="content">
            <div class="part1-outline">
                <div class="regist-pat1">

                    <div class="user">
                        <span>手机号<strong>*</strong></span>
                        <input type="text" name="phone" id="phone" value="\${phone}" disabled="disabled">
                    </div>
                    <div class="address">
                        <div class="add-city">
                            <span>地址<strong>*</strong></span>
                            <select id="seachprov" name="province"
                                    onChange="changeComplexProvince(this.value);">
                                <option value="\${userAdd.province}">\${userAddressName.provinceName}</option>
                                <c:forEach items="${province}" var="province">
                                    <option value="${province.addressId}">${province.name}</option>
                                </c:forEach>
                            </select>&nbsp;&nbsp;
                            <select id="seachcity" name="city"
                                    onChange="changeCity(this.value);">
                                <option value="\${userAdd.city}">\${userAddressName.cityName}</option>
                            </select>&nbsp;&nbsp;
                            <select id="seachdistrict" name="town">
                                <option value="\${userAdd.town}">\${userAddressName.townName}</option>
                            </select>
                            <input type="text"  id="detailadd-input" name="detailAdd" value="\${userAdd.detailAddress}">
                        </div>
                    </div>
                </div>
            </div>
            <div class="regist-pat2">
                <div class="company-name">
                    <span>公司名称<strong>*</strong></span>
                    <input type="text" name="companyName" id="companyname-input" value="\${companyName}"  disabled="disabled">
                </div>
                <div class="company-name">
                    <span>公司简称<strong>*</strong></span>
                    <input type="text" name="stName" id="shortname-input" value="\${stName}">
                </div>
                <div class="contact">
                    <span>联系方式</span>
                    <input type="text" name="userContact" id="contact-input" value="\${userContact}">
                </div>
                <div class="company-dsc">
                    <span> 公司简介<strong>*</strong></span>
                    <textarea name="userDsc" id="companyDesc">\${userDsc}</textarea>
                </div>
                <div class="owner-name">
                    <span>法人姓名<strong>*</strong></span>
                    <input type="text" name="chairtMan" id="ownername-input" value="\${chairtMan}" disabled="disabled">
                </div>
                <div class="owner-name">
                    <span>身份证号<strong>*</strong></span>
                    <input type="text" name="idCard" id="idCard-input" value="\${idCard}" disabled="disabled">
                </div>
                <div class="cert-Card">
                    <span>银行卡号<strong>*</strong></span>
                    <input type="text" name="certCard" id="certcard-input" value="\${cerCard}" disabled="disabled">
                </div>
                <div class="cert-Card">
                    <span>开户行<strong>*</strong></span>
                    <input type="text" name="openBank" id="bankadd-input" value="\${openBank}" disabled="disabled">
                </div>
                <div class="company-logo">
                    <span>公司logo<strong>*</strong></span>
                    <div class="form-group">
                        <img id="img-preview1" name="img-preview" class="img_upload_preview"
                             for="logoimg-file" data-target="img-val" src="\${userLogo}"
                             onclick="$('#logoimg-file').click()"
                             onerror="this.src='${ctx}/resources/ueditor/dialogs/image/images/image.png'"/>
                        <input id="logoimg-file" type="file" name="logoimg-file" style="display: none;"
                               onchange="uploadFile('logoimg-file','img-preview1','logo_img','image')"/>
                        <input name="logo_img" id="logo_img" type="hidden" value="\${userLogo}">
                    </div>
                    <div class='alert alert-warning' id="picsize"><span>建议大小:226px*110px</span></div>
                </div>
                <div class="company-logo">
                    <span>公司相关照片<strong>*</strong></span>
                    <div class="companypic-group">
                        <img id="img-preview5" name="img-preview" class="img_upload_preview"
                             for="companyPics1-file" data-target="img-val" src="\${companyPics[0]}"
                             onclick="$('#companyPics1-file').click()"
                             onerror="this.src='${ctx}/resources/ueditor/dialogs/image/images/image.png'"/>
                        <input id="companyPics1-file" type="file" name="img-file" style="display: none;"
                               onchange="uploadFile('companyPics1-file','img-preview5','companyPics1','image')"/>
                        <input name="companyPics1" id="companyPics1" type="hidden">
                        <div class='alert alert-warning' id="picsize"><span>公司宣传封面:建议大小:1170px*180px</span></div>
                    </div>
                    <%--<div class="companypic-group">--%>
                        <%--<img id="img-preview6" name="img-preview" class="img_upload_preview"--%>
                             <%--for="companyPics2-file" data-target="img-val" src="\${companyPics[1]}"--%>
                             <%--onclick="$('#companyPics2-file').click()"--%>
                             <%--onerror="this.src='${ctx}/resources/ueditor/dialogs/image/images/image.png'"/>--%>
                        <%--<input id="companyPics2-file" type="file" name="img-file" style="display: none;"--%>
                               <%--onchange="uploadFile('companyPics2-file','img-preview6','companyPics2','image')"/>--%>
                        <%--<input name="companyPics2" id="companyPics2" type="hidden">--%>
                        <%--<div class='alert alert-warning' id="picsize"><span>公司场景图片：建议大小:220px*220px</span></div>--%>
                    <%--</div>--%>
                    <%--<div class="companypic-group">--%>
                        <%--<img id="img-preview7" name="img-preview" class="img_upload_preview"--%>
                             <%--for="companyPics3-file" data-target="img-val" src="\${companyPics[2]}"--%>
                             <%--onclick="$('#companyPics3-file').click()"--%>
                             <%--onerror="this.src='${ctx}/resources/ueditor/dialogs/image/images/image.png'"/>--%>
                        <%--<input id="companyPics3-file" type="file" name="img-file" style="display: none;"--%>
                               <%--onchange="uploadFile('companyPics3-file','img-preview7','companyPics3','image')"/>--%>
                        <%--<input name="companyPics3" id="companyPics3" type="hidden">--%>
                        <%--<div class='alert alert-warning' id="picsize"><span>公司场景图片：建议大小:220px*220px</span></div>--%>
                    <%--</div>--%>
                    <%--<div class="companypic-group">--%>
                        <%--<img id="img-preview8" name="img-preview" class="img_upload_preview"--%>
                             <%--for="companyPics4-file" data-target="img-val" src="\${companyPics[3]}}"--%>
                             <%--onclick="$('#companyPics4-file').click()"--%>
                             <%--onerror="this.src='${ctx}/resources/ueditor/dialogs/image/images/image.png'"/>--%>
                        <%--<input id="companyPics4-file" type="file" name="img-file" style="display: none;"--%>
                               <%--onchange="uploadFile('companyPics4-file','img-preview8','companyPics4','image')"/>--%>
                        <%--<input name="companyPics4" id="companyPics4" type="hidden">--%>
                        <%--<div class='alert alert-warning' id="picsize"><span>公司场景图片：建议大小:220px*220px</span></div>--%>
                    <%--</div>--%>
                </div>
                <div class="regist-button">
                    <a href="javascript:updateSub();">提交</a>
                </div>
            </div>
        </div>
    </form>


</script>
<script src="${ctx}/resources/portal/script/imgUp.js" type="text/javascript"></script>
</body>
<script>
    $(function () {
        getuserInfo();
    })
    var user_id = '${uid}';
    function getuserInfo() {
        asyncAjax({
            url: ctx + "/user/mgr/user/"+user_id,
            success: function (res) {
                if (res["result"] == "0") {
                    $("#authInfoTmpl").tmpl(res["data"]).appendTo($("#user-info"));
                }
                else {
                    bootbox.alert(res["msg"]);
                }
            }

        })
    }
    function updateSub() {
        var data = $('#register-form').serializeJson();
        asyncAjax({
            url: ctx + "/user/mgr/updateinfo",
            dataType:"json",
            contentType: "application/json",
            data: JSON.stringify(data),
            success: function (res) {
                if (res["result"] == "0") {
                    bootbox.alert("修改成功!");
                }
                else {
                    bootbox.alert(res["msg"]);
                }
            }

        })

    }
    function sendSms() {
        var phone = $("#phone").val();
        if (/^1[3|4|5|7|8][0-9]{9}$/.test(phone) == false) {
            alert("请输入合法的手机号码!");
            return;
        }
        var data = {
            phone: phone,
            action: "REGISTER_VERIFY"
        }

        asyncAjax({
            url: ctx + "/sms/send",
            data: data,
            success: function (res) {
                if (res["result"] == 0) {
                    alert("验证码已经发送，请注意查收！");
                    $("#sendBtn").val("60s后重新发送").removeAttr("onclick").removeClass("login-submit");
                    var count = 60;
                    var timeInterval = window.setInterval(function () {
                        $("#sendBtn").val(--count + "后重新发送");
                    }, 1000)
                    setTimeout(function () {
                        $("#sendBtn").val("短信验证码").attr("onclick", "sendSms()").addClass("login-submit");
                        window.clearInterval(timeInterval);
                    }, 60000)
                } else {
                    alert(res["msg"]);
                }
            }
        })
    }
    function changeComplexProvince(provinceId) {
        var data ={provinceId:provinceId}
        asyncAjax({
            url: ctx + "/area/getAllcity?" + $.param(data).replace(/(%5D|%5B)/g, ""),
            beforeSend: function () {
                $("#seachcity").html('<option value="">请选择</option>');
                $("#seachdistrict").html('<option value="">请选择</option>');
            },
            success: function (res) {
                if (res["result"] == "0") {
                    if (!isEmpty(res["data"])) {
                        $.each(res["data"], function (idx, item) {
                            $("#seachcity").append('<option value=\"' + item["addressId"] + '\">' + item["shortName"] + '</option>')
                        })
                    } else {
                    }
                } else {
                    bootbox.alert(res["msg"]);
                }
            }
        })

    }
    function changeCity(cityId) {
        var data ={cityId:cityId}
        asyncAjax({
            url: ctx + "/area/getAllarea?" + $.param(data).replace(/(%5D|%5B)/g, ""),
            beforeSend: function () {
                $("#seachdistrict").html('<option value="">请选择</option>');
            },
            success: function (res) {
                if (res["result"] == "0") {
                    if (!isEmpty(res["data"])) {
                        $.each(res["data"], function (idx, item) {
                            $("#seachdistrict").append('<option value=\"' + item["addressId"] + '\">' + item["shortName"] + '</option>')
                        })
                    } else {
                    }
                } else {
                    bootbox.alert(res["msg"]);
                }
            }
        })

    }
</script>
</html>
